//
//  MFWVersionUtils.h
//  TravelGuideMdd
//
//  Created by Song Xiaofeng on 13-6-17.
//  Copyright (c) 2013年 Mafengwo Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)	([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

#define IOS6_PLUS SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")
#define IOS7_PLUS SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
#define IOS8_PLUS SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
#define IOS9_PLUS SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"9.0")

#define IOS_LESS_10 SYSTEM_VERSION_LESS_THAN(@"10.0")


#define IS_IOS7 IOS7_PLUS
#define IF_IOS7PLUS if(IOS7_PLUS)
#define IF_IOS8PLUS if(IOS8_PLUS)


@interface MFWVersionUtils : NSObject

/**
 * 获取app版本号
 * 1. 优先取 CFBundleShortVersionString
 * 2. 如果步骤1没有取到则取 CFBundleVersion
 */
+ (NSString*)appVersion;


/**
 * AppStore中使用的version
 * CFBundleShortVersionString
 */
+ (NSString*)markingVersion;

/**
 * CFBundleVersion
 */
+ (NSString*)technicalVersion;

/**
 * 版本号比较
 * eg:
 *  1.1.0  < 10.0.0
 *  1.2.3.4 > 1.2.3
 *  1.2 == 1.2.0
 */
+ (NSComparisonResult)compareOldVersion:(NSString*)oldVersion toNewVersion:(NSString*)newVersion;

@end
